package com.principle.factory.factorymethod.pizzastore.order;


import com.principle.factory.factorymethod.pizzastore.pizza.Pizza;

import java.io.BufferedReader;
import java.io.InputStreamReader;

public abstract class OrderPizza {
    //定义一个抽象方法，createPizza 让各个工厂子类自己实现
    abstract Pizza createPizza(String orderType);
    //构造器
    public OrderPizza(){
        Pizza pizza =null;
        String type;
        do {
            type=gettype();
            pizza = createPizza(type);//抽象方法，由工厂子类完成
            pizza.prepare();;
            pizza.bake();
            pizza.cut();
            pizza.box();
        } while (true);
    }
    private String gettype(){
        try {
            BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
            System.out.println("input pizza type");
            String line = reader.readLine();
            return line;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return "";
    }
}
